// orderresult.js
var api = require('../../utils/api');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    hiddenmodalnotice: true,
    hiddenmodalinput: true,
    hiddenmodalrefund:true,
    nocancel:true,
    order_detail: {
    }
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var id = options.id;
    var createId = options.createId;
    var orderNo = options.orderNo;
    var ticketId = options.ticketId;
    var url = api.searchRefundTicket();
    var params = { "id": id, "createId": createId, "orderNo": orderNo, "ticketIds": [ticketId]};
    api.request(url, 'POST', params, function (res, err) {
      debugger;
      that.setData({"order_detail":res,"id":id,"createId":createId,"orderNo":orderNo,"ticketId":ticketId});
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },orderback: function (e) {
	  
	  var url = api.refundTicket();
	  var opendId = app.globalData.opendId;
	  var orderId = this.data.id;
	  var ticketId = this.data.ticketId;
	  debugger;
	  var params = { "opendId": opendId, "orderId": orderId, "ticketId": ticketId, "formId": e.detail.formId};
	
	  api.request(url, 'POST', params, function (res, err) {
		  var orderId = res.orderId;
		  var orderNo = res.orderNo;
		  var refundNo = res.refundNo;
		  var refundPrice = res.refundPrice;
		  var oldPrice = res.oldPrice;
		  var openid = res.openid;
		  var refundRadio = res.refundRadio;
	
		  wx.navigateTo({
		      url: '../orderbackresult/orderback_result?orderId=' + orderId + "&orderNo=" + orderNo + "&refundNo=" + refundNo + "&refundPrice=" + refundPrice+"&oldPrice="+oldPrice+"&openid="+openid+"&refundRadio="+refundRadio,
		  })
	  });
	/*  
    wx.redirectTo({
      url: '../orderbackresult/orderback_result'
    })*/
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  gpshowModal: function () {
    this.setData({
      hiddenmodalnotice: !this.data.hiddenmodalnotice
    })
  },
  gpcancel: function () {
    this.setData({
      hiddenmodalnotice: true
    })
  },
  gpconfirm: function () {
    this.setData({
      hiddenmodalnotice: !this.data.hiddenmodalnotice
    })
  },
  modalinput: function () {
    this.setData({
      hiddenmodalinput: !this.data.hiddenmodalinput
    })
  },
  skcancel: function () {
    this.setData({
      hiddenmodalinput: true
    })
  },
  skconfirm: function () {
    this.setData({
      hiddenmodalinput: !this.data.hiddenmodalinput
    })
  },
  
  modalrefund: function () {
    this.setData({
      hiddenmodalrefund: !this.data.hiddenmodalrefund
    })
  },
  recancel: function () {
    this.setData({
      hiddenmodalrefund: true
    })
  },
  reconfirm: function () {
    this.setData({
      hiddenmodalrefund: !this.data.hiddenmodalrefund
    })
  },
  /**
   * 二维码弹框
   */
  /**在线选座弹框
   * 
   */
  showModal: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  hideModal: function () {
    // 隐藏遮罩层
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },
  cancelRefund:function(){
    debugger;
	  wx.reLaunch({
	      url: '../index/index'
	    })
  }
  
})